#!/usr/bin/python
'''

Wizards.py contains classes and functions for wizard interfaces.

'''
ident = '$Id: account_manager.py 112 2006-06-07 17:28:17Z trevor $'
import wx, sys
from wx.lib.mixins.listctrl 	import ColumnSorterMixin
import common
import icon_manager
import images
import webbrowser
import rex
import account_ui
import about
import tracer
import wx.wizard as wiz
import wx.lib.hyperlink as link

ACCOUNT_WIZARD_ID = 6000
WELCOME_MESSAGE = '''The Etelos Development Environment features client-side software applications that 
provide a rapid development environment for developers who want to modify Etelos 
Applications or create new solutions; whether hosted by the client or by an Etelos 
Certified Hosting Partner (ECHP).

Etelos makes developing easy by providing the Etelos Scripting language to manage 
application design.  Etelos Scripting support is accessible through popup menus and 
interactive help.  Just a simple right click and you can create many forms, lists 
of contacts, content or even a secure intranet...  in English, so they are easy to 
understand and modify.
'''

GET_ESDNET = '''If you don't already have one, now is a great time to set up an ESDNet subscription.

ESDNet is an online resource dedicated to Etelos Systems Developers and their projects.
Featuring online searchable documentation, feature requests, updates, downloads, 
templates and access to cool code. ESDNet is a living knowledge base of information 
to help you build custom applications on Etelos quicker than ever before.

Get your subscription for free at:'''

GET_TRIAL = '''In order to try EDE you will need a host for your site.  If you haven't already
partnered with an Etelos Certified Hosting Partner (ECHP), you can take advantage of our 
promotional trial hosting.

Sign up at at:'''

VISIT_THE_STORE = '''Etelos value added resellers have created 100's of pre-built applications that allow
utterly non-technical users to perform sophisticated tasks solely through filling 
out forms. Existing applications can add articles to a web database, create 
personalized newsletters, run email campaigns, and build interactive survey forms... 
and so much more.  Best of all, these applications can be customized further through
the use of EDE.

Remember to visit the store at:'''

 
class EDE_WizardPage( wiz.WizardPageSimple ):
	def __init__( self, parent, title, image=None ):
		wiz.WizardPageSimple.__init__( self, parent )
		if not image:
			self.image = images.getBigESMBitmap()
		else :
			self.image = image
		self.initPageTitle( self, title, self.image )
	
	def initPageTitle( self, wizPg, title, image=None ):
		# Set up the sizers
		sizer = wx.BoxSizer( wx.VERTICAL )
		wizPg.SetSizer( sizer )
		title_sizer = wx.BoxSizer( wx.HORIZONTAL )
		sizer.AddSizer( title_sizer )
		# Add the image for the page
		if image:
			staticBitmap = wx.StaticBitmap( wizPg, -1, image )
			title_sizer.AddWindow( staticBitmap, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
		# Add the title for the page
		title = wx.StaticText( wizPg, -1, title )
		title.SetFont( wx.Font( 16, wx.SWISS, wx.NORMAL, wx.BOLD ) )
		title_sizer.AddWindow( title, 0, wx.ALIGN_LEFT|wx.ALIGN_BOTTOM|wx.ALL, 5 )
		# Add the separator line
		sizer.AddWindow( wx.StaticLine( wizPg, -1 ), 0, wx.EXPAND|wx.ALL, 5 )
		self.sizer = sizer
		self.title_sizer = title_sizer

	def addContent( self, content, id=0, align=wx.ALIGN_LEFT|wx.ALIGN_BOTTOM|wx.ALL, proportion=5 ):
		self.sizer.AddWindow( content, id, align, proportion )
		
		
		
def showFirstUseWizard():
	wizard = wiz.Wizard( None, ACCOUNT_WIZARD_ID, "Account Setup Wizard" )
	# Set the wizard icon
	icon = icon_manager.get_icon( "ESM" )
	#wizard.SetIcon( icon )
	common.dprint( "wizards.showFirstUseWizard :: Instantiated the wizard" )
	# Build the pages
	page1 = EDE_WizardPage( wizard, "Welcome to EDE!" )
	page1.addContent( wx.StaticText( page1, -1, WELCOME_MESSAGE ) )
	
	page2 = EDE_WizardPage( wizard, "Set up your ESDNet account" )
	page2_link = link.HyperLinkCtrl( page2, wx.ID_ANY, "http://www.etelos.com/store?item=17", URL="http://www.etelos.com/store?item=17" )
	page2.addContent( wx.StaticText( page2, -1, GET_ESDNET ) )	
	page2.addContent( page2_link )
	
	page3 = EDE_WizardPage( wizard, "Set up a trial hosting account" )
	page3_link = link.HyperLinkCtrl( page3, wx.ID_ANY, "http://www.etelos.com/store?item=8", URL="http://www.etelos.com/store?item=8" )
	page3.addContent( wx.StaticText( page3, -1, GET_TRIAL ) )
	page3.addContent( page3_link )
	
	page4 = EDE_WizardPage( wizard, "Visit the Etelos store" )
	page4_link = link.HyperLinkCtrl( page4, wx.ID_ANY, "http://www.etelos.com/store", URL="http://www.etelos.com/store" )
	page4.addContent( wx.StaticText( page4, -1, VISIT_THE_STORE ) )	
	page4.addContent( page4_link )	
	common.dprint( "wizards.showFirstUseWizard :: Built the pages" )
	
	# Chain the pages
	wiz.WizardPageSimple_Chain( page1, page2 )
	wiz.WizardPageSimple_Chain( page2, page3 )
	wiz.WizardPageSimple_Chain( page3, page4 )
	common.dprint( "wizards.showFirstUseWizard :: Chained the pages" )
	# Run the wizard
	wizard.FitToPage( page1 )
	wizard.RunWizard( page1 )
	common.dprint( "wizards.showFirstUseWizard :: Finished displaying the wizard" )
	wizard.Destroy()
	
	
	